<script>
function random() {
  if (Math.random() < 0.7) {
    return 0
  }
  return 1
}

function rand() {
  var first, second
  while(true) {
    first = random()
    second = random()

    if (first == 1 && second == 0) {
      return 1
    } else if (first == 0 && second == 1) {
      return 0
    }
  }
}

function rand2() {
  var first = random()
  var second = random()

  if (first == 1 && second == 0) {
    return 1
  }
  if (first == 0 && second == 1) {
    return 0
  }

  return rand2()
}
</script>
